Back to course home
0% completed
Vote For New Content
Microsoft Medium Problems
Nth Digit (medium)
Solution: Nth Digit
Restore IP Addresses (medium)
Solution: Restore IP Addresses
Find Original Array From Doubled Array (medium)
Solution: Find Original Array From Doubled Array
Reverse Words in a String II (medium)
Solution: Reverse Words in a String II
Longest Arithmetic Subsequence (medium)
Solution: Longest Arithmetic Subsequence
Matchsticks to Square (medium)
Solution: Matchsticks to Square
Score of Parentheses (medium)
Solution: Score of Parentheses
Maximum Length of a Concatenated String with Unique Characters (medium)
Solution: Maximum Length of a Concatenated String with Unique Characters
Inorder Successor in BST (medium)
Solution: Inorder Successor in BST
Distribute Coins in Binary Tree (medium)
Solution: Distribute Coins in Binary Tree
Spiral Matrix (medium)
Solution: Spiral Matrix
Delete Node in a BST (medium)
Solution: Delete Node in a BST
Sum of Subarray Minimums (medium)
Solution: Sum of Subarray Minimums
Rotate Image (medium)
Solution: Rotate Image
Combinations (medium)
Solution: Combinations
Maximum Level Sum of a Binary Tree (medium)
Solution: Maximum Level Sum of a Binary Tree
Multiply Strings (medium)
Solution: Multiply Strings
Best Time to Buy and Sell Stock II (medium)
Solution: Best Time to Buy and Sell Stock II
Largest Palindromic Number (medium)
Solution: Largest Palindromic Number
Remove Duplicate Letters (medium)
Solution: Remove Duplicate Letters
Next Permutation (medium)
Solution: Next Permutation
132 Pattern (medium)
Solution: 132 Pattern
Valid Sudoku (medium)
Solution: Valid Sudoku
Number of Islands (medium)
Solution: Number of Islands
Buildings With an Ocean View (medium)
Solution: Buildings With an Ocean View
Microsoft Hard Problems
Regular Expression Matching (hard)
Solution: Regular Expression Matching
First Missing Positive (hard)
Solution: First Missing Positive
Largest Rectangle in Histogram (hard)
Solution: Largest Rectangle in Histogram
Sliding Window Maximum (hard)
Solution: Sliding Window Maximum
Count Unique Characters of All Substrings of a Given String (hard)
Solution: Count Unique Characters of All Substrings of a Given String
Word Ladder (hard)
Solution: Word Ladder
Word Ladder II (hard)
Solution: Word Ladder II
Number of Flowers in Full Bloom (hard)
Solution: Number of Flowers in Full Bloom
Median of Two Sorted Arrays (hard)
Solution: Median of Two Sorted Arrays
Longest Valid Parentheses (hard)
Solution: Longest Valid Parentheses
Merge Two Sorted Lists (easy)
Problem Statement
Given the head of two sorted linked lists, l1 and l2.
Return a new sorted list created by merging together the nodes of the first two lists.
Examples
-
Example 1:
- Input:
[1, 3, 5] [2, 4, 6] - Expected Output:
[1, 2, 3, 4, 5, 6] - Justification: Merging the two sorted linked lists, node by node, results in a single sorted linked list containing all elements from both input lists.
- Input:
-
Example 2:
- Input:
[2, 4, 6] [1, 3, 5] - Expected Output:
[1, 2, 3, 4, 5, 6] - Justification: Both lists are in ascending order; merging them node by node in ascending order gives us the sorted linked list with all elements.
- Input:
-
Example 3:
- Input:
[1, 2, 3] [4, 5, 6] - Expected Output:
[1, 2, 3, 4, 5, 6] - Justification: As the first list contains all smaller elements, combining them results in a new list with elements from the first list followed by the second one.
- Input:
Constraints:
- The number of nodes in both lists is in the range
[0, 50]. -100 <= Node.val <= 100- Both
list1andlist2are sorted in non-decreasing order.
Try it yourself
Try solving this question here:
Java
Saved to Cloud
. . . .
Solution: Find the Index of the First Occurrence in a String
Solution: Merge Two Sorted Lists
Mark as Completed
On this page
Problem Statement
Examples
Try it yourself